package com.hc.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hc.domain.BlogCategoryCharge;
import com.hc.dto.ListBlogCategoryChargeDTO;
import com.hc.mapper.BlogCategoryChargeMapper;
import com.hc.service.BlogCategoryChargeService;
import com.hc.vo.BlogCategoryChargeVO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BlogCategoryChargeServiceImpl extends ServiceImpl<BlogCategoryChargeMapper, BlogCategoryCharge> implements BlogCategoryChargeService {

    @Resource
    private BlogCategoryChargeMapper blogCategoryChargeMapper;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public int createBlogCategoryCharge(BlogCategoryChargeVO blogCategoryChargeVO) {
        int res = blogCategoryChargeMapper.insertBlogCategoryCharge(blogCategoryChargeVO);
        return res;
    }

    @Override
    public String getBlogCategoryChargeIntroById(Integer id) {
        String res = blogCategoryChargeMapper.selectBlogCategoryChargeIntroById(id);
        return res;
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public int deleteBlogCategoryChargeById(Integer id) {
        int res = blogCategoryChargeMapper.deleteBlogCategoryChargeById(id);
        return res;
    }

    @Override
    public List<ListBlogCategoryChargeDTO> listBlogCategoryChargeDTOsByUserId(Integer userId) {
        List<ListBlogCategoryChargeDTO> res = blogCategoryChargeMapper.selectBlogCategoryChargeDTOs(userId);
        return res;
    }

    @Override
    public List<ListBlogCategoryChargeDTO> listAllBlogCategoryChargeDTOs() {
        List<ListBlogCategoryChargeDTO> res = blogCategoryChargeMapper.selectBlogCategoryChargeDTOs(null);
        return res;
    }
}
